home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Development Tools & Languages / Macintosh Common Lisp Related / interfaces / Components.lisp < prev    next >
Encoding:
Text File  |  1994-09-13  |  12.7 KB  |  327 lines  |  [TEXT/CCL2]

  1.  
  2. (in-package :TRAPS)             ; ************************************************************
  3. ;     Created: Wednesday, April 21, 1993
  4. ;     Modified:    Wed, Dec 1, 1993 16:39:45
  5. ;     Components.p
  6. ;     Pascal Interface to the Macintosh Libraries
  7. ;     
  8. ;     Copyright Apple Computer, Inc. 1990-93
  9. ;     All rights reserved
  10. ; ************************************************************
  11.  
  12. ; $IFC UNDEFINED UsingIncludes
  13. ; $SETC UsingIncludes := 0
  14. ; $ENDC
  15.  
  16. ; $IFC NOT UsingIncludes
  17.  
  18. ; $ENDC
  19.  
  20. ; $IFC UNDEFINED UsingComponents
  21. ; $SETC UsingComponents := 1
  22.  
  23. ; $I+
  24. ; $SETC ComponentsIncludes := UsingIncludes
  25. ; $SETC UsingIncludes := 1
  26. ; $IFC UNDEFINED UsingTypes
  27.  
  28. (require-interface 'TYPES)      ; $I $$Shell(PInterfaces)Types.p
  29. ; $ENDC
  30. ; $IFC UNDEFINED UsingTypes
  31.  
  32. (require-interface 'MEMORY)     ; $I $$Shell(PInterfaces)Memory.p
  33. ; $ENDC
  34. ; $SETC UsingIncludes := ComponentsIncludes
  35.  
  36. ; $IFC UNDEFINED gestaltComponentMgrDeclared
  37. ; $SETC gestaltComponentMgrDeclared := True
  38. (defconstant $gestaltComponentMgr :|cpnt|)
  39. ; $ENDC
  40.  
  41. (defconstant $kAnyComponentType 0)
  42. (defconstant $kAnyComponentSubType 0)
  43. (defconstant $kAnyComponentManufacturer 0)
  44. (defconstant $kAnyComponentFlagsMask 0)
  45.  
  46. (defconstant $cmpWantsRegisterMessage #X80000000)
  47.  
  48. ;  Component Resource Extension flags 
  49. (defconstant $componentDoAutoVersion 1)
  50. (defconstant $componentWantsUnregister 2)
  51. (defconstant $componentAutoVersionIncludeFlags 4)
  52.  
  53. (defrecord ComponentDescription 
  54.    (componentType :OSTYPE)      ;  A unique 4-byte code indentifying the command set 
  55.    (componentSubType :OSTYPE)   ;  Particular flavor of this instance 
  56.    (componentManufacturer :OSTYPE);  Vendor indentification 
  57.    (componentFlags :SIGNED-LONG);  8 each for Component,Type,SubType,Manuf/revision 
  58.    (componentFlagsMask :SIGNED-LONG);  Mask for specifying which flags to consider in search, zero during registration 
  59.    )
  60.  
  61. (defrecord ResourceSpec 
  62.    (resType :OSTYPE)            ;  4-byte code  
  63.    (resId :SIGNED-INTEGER)      ;     
  64.    )
  65.  
  66. (def-mactype :COMPONENTRESOURCEPTR (find-mactype :POINTER))
  67. (def-mactype :COMPONENTRESOURCEHANDLE (find-mactype :HANDLE))
  68. (defrecord (ComponentResource :handle) 
  69.    (cd :COMPONENTDESCRIPTION)   ;  Registration parameters 
  70.    (component :RESOURCESPEC)    ;  resource where Component code is found 
  71.    (componentName :RESOURCESPEC);  name string resource 
  72.    (componentInfo :RESOURCESPEC);  info string resource 
  73.    (componentIcon :RESOURCESPEC);  icon resource 
  74.    )
  75.  
  76. (defrecord ComponentResourceExtension 
  77.    (componentVersion :SIGNED-LONG);  version of Component 
  78.    (componentRegisterFlags :SIGNED-LONG);  flags for registration 
  79.    (componentIconSuite :SIGNED-INTEGER);  resource id of Icon Suite 
  80.    )
  81.  
  82. (def-mactype :COMPONENTPTR (find-mactype :HANDLE))
  83. (def-mactype :COMPONENT (find-mactype :POINTER))
  84. (defrecord (ComponentRecord :handle) 
  85.    (data (:ARRAY :SIGNED-LONG 1))
  86.    )
  87.  
  88. (def-mactype :COMPONENTINSTANCE (find-mactype :POINTER))
  89. (defrecord ComponentInstanceRecord 
  90.    (data (:ARRAY :SIGNED-LONG 1))
  91.    )
  92.  
  93. ;  Structure received by Component:  
  94. (defrecord ComponentParameters 
  95.    (flags :CHARACTER)           ;  call modifiers: sync/async, deferred, immed, etc 
  96.    (paramSize :CHARACTER)       ;  size in bytes of actual parameters passed to this call 
  97.    (what :SIGNED-INTEGER)       ;  routine selector, negative for Component management calls 
  98.    (params (:ARRAY :SIGNED-LONG 1));  actual parameters for the indicated routine 
  99.    )
  100.  
  101. (def-mactype :COMPONENTRESULT (find-mactype :SIGNED-LONG))
  102.  
  103. (def-mactype :COMPONENTROUTINE (find-mactype :POINTER))
  104.  
  105. (def-mactype :COMPONENTFUNCTION (find-mactype :POINTER))
  106.  
  107. ; ******************************************************
  108. ; * Required Component routines
  109. ; ******************************************************
  110.  
  111. (defconstant $kComponentOpenSelect -1);  ComponentInstance for this open 
  112. (defconstant $kComponentCloseSelect -2);  ComponentInstance for this close 
  113. (defconstant $kComponentCanDoSelect -3);  selector # being queried 
  114. (defconstant $kComponentVersionSelect -4);  no params 
  115. (defconstant $kComponentRegisterSelect -5);  no params 
  116. (defconstant $kComponentTargetSelect -6);  ComponentInstance for top of call chain 
  117. (defconstant $kComponentUnregisterSelect -7);  no params 
  118.  
  119. ;  Set Default Component flags 
  120. (defconstant $defaultComponentIdentical 0)
  121. (defconstant $defaultComponentAnyFlags 1)
  122. (defconstant $defaultComponentAnyManufacturer 2)
  123. (defconstant $defaultComponentAnySubType 4)
  124. (defconstant $defaultComponentAnyFlagsAnyManufacturer (+ #$DEFAULTCOMPONENTANYFLAGS #$DEFAULTCOMPONENTANYMANUFACTURER))
  125. (defconstant $defaultComponentAnyFlagsAnyManufacturerAnySubType (+ #$DEFAULTCOMPONENTANYFLAGS (+ #$DEFAULTCOMPONENTANYMANUFACTURER #$DEFAULTCOMPONENTANYSUBTYPE)))
  126.  
  127. ;  errors from component manager & components 
  128. (defconstant $invalidComponentID -3000)
  129. (defconstant $validInstancesExist -3001)
  130. (defconstant $componentNotCaptured -3002)
  131. (defconstant $componentDontRegister -3003)
  132.  
  133. (defconstant $badComponentInstance #X80008001)
  134. (defconstant $badComponentSelector #X80008002)
  135.  
  136. ;  *******************************************************
  137. ; *                                                     *
  138. ; *              APPLICATION LEVEL CALLS                *
  139. ; *                                                     *
  140. ; *******************************************************
  141. ; * Component Database Add, Delete, and Query Routines 
  142. ; *******************************************************
  143. ;  
  144.  
  145. (deftrap _registercomponent ((cd :componentdescription) (componententrypoint :pointer) (global :signed-integer) (componentname :handle) (componentinfo :handle) (componenticon :handle))
  146.    (:stack (:pointer :componentrecord))
  147.    (:stack-trap #xA82A :d0 1 cd componententrypoint global componentname componentinfo componenticon))
  148.  
  149. (deftrap _registercomponentresource ((tr (:handle :componentresource)) (global :signed-integer))
  150.    (:stack (:pointer :componentrecord))
  151.    (:stack-trap #xA82A :d0 18 tr global))
  152.  
  153. (deftrap _unregistercomponent ((acomponent (:pointer :componentrecord)))
  154.    (:stack :signed-integer)
  155.    (:stack-trap #xA82A :d0 2 acomponent))
  156.  
  157.  
  158. (deftrap _findnextcomponent ((acomponent (:pointer :componentrecord)) (looking :componentdescription))
  159.    (:stack (:pointer :componentrecord))
  160.    (:stack-trap #xA82A :d0 4 acomponent looking))
  161.  
  162. (deftrap _countcomponents ((looking :componentdescription))
  163.    (:stack :signed-long)
  164.    (:stack-trap #xA82A :d0 3 looking))
  165.  
  166.  
  167. (deftrap _getcomponentinfo ((acomponent (:pointer :componentrecord)) (cd (:pointer :componentdescription)) (componentname :handle) (componentinfo :handle) (componenticon :handle))
  168.    (:stack :signed-integer)
  169.    (:stack-trap #xA82A :d0 5 acomponent cd componentname componentinfo componenticon))
  170.  
  171. (deftrap _getcomponentlistmodseed nil
  172.    (:stack :signed-long)
  173.    (:stack-trap #xA82A :d0 6))
  174.  
  175. ;  *******************************************************
  176. ; * Component Instance Allocation and dispatch routines 
  177. ; *******************************************************
  178. ;  
  179.  
  180. (deftrap _opencomponent ((acomponent (:pointer :componentrecord)))
  181.    (:stack (:pointer :componentinstancerecord))
  182.    (:stack-trap #xA82A :d0 7 acomponent))
  183.  
  184. (deftrap _closecomponent ((acomponentinstance (:pointer :componentinstancerecord)))
  185.    (:stack :signed-integer)
  186.    (:stack-trap #xA82A :d0 8 acomponentinstance))
  187.  
  188.  
  189. (deftrap _getcomponentinstanceerror ((acomponentinstance (:pointer :componentinstancerecord)))
  190.    (:stack :signed-integer)
  191.    (:stack-trap #xA82A :d0 10 acomponentinstance))
  192.  
  193. ;   direct calls to the Components  
  194.  
  195. (deftrap _componentfunctionimplemented ((ci (:pointer :componentinstancerecord)) (ftnnumber :signed-integer))
  196.    (:stack :signed-long)
  197.    (:stack-trap #xA82A :d0 0 ci ftnnumber ((+ (ash 2 16) 65533) :signed-longint)))
  198.  
  199. (deftrap _getcomponentversion ((ci (:pointer :componentinstancerecord)))
  200.    (:stack :signed-long)
  201.    (:stack-trap #xA82A :d0 0 ci ((+ (ash 0 16) 65532) :signed-longint)))
  202.  
  203. (deftrap _componentsettarget ((ci (:pointer :componentinstancerecord)) (target (:pointer :componentinstancerecord)))
  204.    (:stack :signed-long)
  205.    (:stack-trap #xA82A :d0 0 ci target ((+ (ash 4 16) 65530) :signed-longint)))
  206.  
  207. ; ****************************************************
  208. ; *                                                    *
  209. ; *               CALLS MADE BY Components             *
  210. ; *                                                    *
  211. ; ******************************************************
  212.  
  213. ;  *******************************************************
  214. ; * Component Management routines
  215. ; *******************************************************
  216. ;  
  217.  
  218. (deftrap _setcomponentinstanceerror ((acomponentinstance (:pointer :componentinstancerecord)) (theerror :signed-integer))
  219.    nil
  220.    (:stack-trap #xA82A :d0 11 acomponentinstance theerror))
  221.  
  222.  
  223. (deftrap _getcomponentrefcon ((acomponent (:pointer :componentrecord)))
  224.    (:stack :signed-long)
  225.    (:stack-trap #xA82A :d0 16 acomponent))
  226.  
  227. (deftrap _setcomponentrefcon ((acomponent (:pointer :componentrecord)) (therefcon :signed-long))
  228.    nil
  229.    (:stack-trap #xA82A :d0 17 acomponent therefcon))
  230.  
  231.  
  232. (deftrap _opencomponentresfile ((acomponent (:pointer :componentrecord)))
  233.    (:stack :signed-integer)
  234.    (:stack-trap #xA82A :d0 21 acomponent))
  235.  
  236. (deftrap _closecomponentresfile ((refnum :signed-integer))
  237.    (:stack :signed-integer)
  238.    (:stack-trap #xA82A :d0 24 refnum))
  239.  
  240. ;  *******************************************************
  241. ; * Component Instance Management routines
  242. ; *******************************************************
  243. ;  
  244.  
  245. (deftrap _getcomponentinstancestorage ((acomponentinstance (:pointer :componentinstancerecord)))
  246.    (:stack :handle)
  247.    (:stack-trap #xA82A :d0 12 acomponentinstance))
  248.  
  249. (deftrap _setcomponentinstancestorage ((acomponentinstance (:pointer :componentinstancerecord)) (thestorage :handle))
  250.    nil
  251.    (:stack-trap #xA82A :d0 13 acomponentinstance thestorage))
  252.  
  253.  
  254. (deftrap _getcomponentinstancea5 ((acomponentinstance (:pointer :componentinstancerecord)))
  255.    (:stack :signed-long)
  256.    (:stack-trap #xA82A :d0 14 acomponentinstance))
  257.  
  258. (deftrap _setcomponentinstancea5 ((acomponentinstance (:pointer :componentinstancerecord)) (thea5 :signed-long))
  259.    nil
  260.    (:stack-trap #xA82A :d0 15 acomponentinstance thea5))
  261.  
  262.  
  263. (deftrap _countcomponentinstances ((acomponent (:pointer :componentrecord)))
  264.    (:stack :signed-long)
  265.    (:stack-trap #xA82A :d0 19 acomponent))
  266.  
  267. ;   useful helper routines for convenient method dispatching  
  268.  
  269. (deftrap _callcomponentfunction ((params :componentparameters) (func :pointer))
  270.    (:stack :signed-long)
  271.    (:stack-trap #xA82A :d0 255 params func))
  272.  
  273. (deftrap _callcomponentfunctionwithstorage ((storage :handle) (params :componentparameters) (func :pointer))
  274.    (:stack :signed-long)
  275.    (:stack-trap #xA82A :d0 255 storage params func))
  276.  
  277. (deftrap _delegatecomponentcall ((originalparams :componentparameters) (ci (:pointer :componentinstancerecord)))
  278.    (:stack :signed-long)
  279.    (:stack-trap #xA82A :d0 36 originalparams ci))
  280.  
  281.  
  282. (deftrap _setdefaultcomponent ((acomponent (:pointer :componentrecord)) (flags :signed-integer))
  283.    (:stack :signed-integer)
  284.    (:stack-trap #xA82A :d0 30 acomponent flags))
  285.  
  286. (deftrap _opendefaultcomponent ((componenttype :ostype) (componentsubtype :ostype))
  287.    (:stack (:pointer :componentinstancerecord))
  288.    (:stack-trap #xA82A :d0 33 componenttype componentsubtype))
  289.  
  290. (deftrap _capturecomponent ((capturedcomponent (:pointer :componentrecord)) (capturingcomponent (:pointer :componentrecord)))
  291.    (:stack (:pointer :componentrecord))
  292.    (:stack-trap #xA82A :d0 28 capturedcomponent capturingcomponent))
  293.  
  294. (deftrap _uncapturecomponent ((acomponent (:pointer :componentrecord)))
  295.    (:stack :signed-integer)
  296.    (:stack-trap #xA82A :d0 29 acomponent))
  297.  
  298. (deftrap _registercomponentresourcefile ((resrefnum :signed-integer) (global :signed-integer))
  299.    (:stack :signed-long)
  300.    (:stack-trap #xA82A :d0 20 resrefnum global))
  301.  
  302. (deftrap _getcomponenticonsuite ((acomponent (:pointer :componentrecord)) (iconsuite (:pointer :handle)))
  303.    (:stack :signed-integer)
  304.    (:stack-trap #xA82A :d0 42 acomponent iconsuite))
  305.  
  306. ; $ENDC                         ;  UsingComponents 
  307.  
  308. ; $IFC NOT UsingIncludes
  309.  
  310. ; $ENDC
  311.  
  312.  
  313. (export '($BADCOMPONENTSELECTOR $BADCOMPONENTINSTANCE $COMPONENTDONTREGISTER
  314.           $COMPONENTNOTCAPTURED $VALIDINSTANCESEXIST $INVALIDCOMPONENTID
  315.           $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURERANYSUBTYPE
  316.           $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURER $DEFAULTCOMPONENTANYSUBTYPE
  317.           $DEFAULTCOMPONENTANYMANUFACTURER $DEFAULTCOMPONENTANYFLAGS
  318.           $DEFAULTCOMPONENTIDENTICAL $KCOMPONENTUNREGISTERSELECT
  319.           $KCOMPONENTTARGETSELECT $KCOMPONENTREGISTERSELECT
  320.           $KCOMPONENTVERSIONSELECT $KCOMPONENTCANDOSELECT
  321.           $KCOMPONENTCLOSESELECT $KCOMPONENTOPENSELECT
  322.           $COMPONENTAUTOVERSIONINCLUDEFLAGS $COMPONENTWANTSUNREGISTER
  323.           $COMPONENTDOAUTOVERSION $CMPWANTSREGISTERMESSAGE
  324.           $KANYCOMPONENTFLAGSMASK $KANYCOMPONENTMANUFACTURER
  325.           $KANYCOMPONENTSUBTYPE $KANYCOMPONENTTYPE $GESTALTCOMPONENTMGR))
  326. (provide-interface 'Components)